package com.yanqu.road.server.gameplayer.module.drugstore;

import com.yanqu.road.entity.drugstore.UserDrugChuFangOrderData;
import com.yanqu.road.server.manger.drugstore.DrugStoreMgr;

import java.util.HashMap;
import java.util.Map;

public class DrugAutoExecuteResult {

    boolean landStateChange;

    Map<Long, UserDrugChuFangOrderData> orderStateChangeMap = new HashMap<>();

    boolean userDataChange;

    long currentTimeMillis = System.currentTimeMillis();

    /**
     * 离线后的种植起始时间/诊桌诊疗起始时间
     * 起始结算时间（该时间与当前时间的间隔为服务端推进时间范围）
     * @param lastSettleTime 最后结算时间
     */
    public long getOffLineStartSettleTime(long  lastSettleTime){
        long limitTime = DrugStoreMgr.getOffLineLimitTime();
        if (offLineTime > limitTime && limitTime > 0) {
            return Math.max(lastSettleTime, currentTimeMillis - limitTime);
        } else {
            if(offLineTime == 0){
                //在界面
                return Math.min(lastSettleTime, currentTimeMillis);
            }
            return Math.max(lastSettleTime, currentTimeMillis - offLineTime);
        }
    }

    /**
     * 离线时间
     */
    long offLineTime;

    public DrugAutoExecuteResult(long offLineTime) {
        this.offLineTime = offLineTime;
    }

    public long getCurrentTimeMillis() {
        return currentTimeMillis;
    }

    public long getOffLineTime() {
        return offLineTime;
    }

    public boolean isLandStateChange() {
        return landStateChange;
    }

    public void setLandStateChange(boolean landStateChange) {
        this.landStateChange = landStateChange;
    }

    public Map<Long, UserDrugChuFangOrderData> getOrderStateChangeMap() {
        return orderStateChangeMap;
    }

    public void setOrderStateChangeMap(Map<Long, UserDrugChuFangOrderData> orderStateChangeMap) {
        this.orderStateChangeMap = orderStateChangeMap;
    }

    public boolean isUserDataChange() {
        return userDataChange;
    }

    public void setUserDataChange(boolean userDataChange) {
        this.userDataChange = userDataChange;
    }
}
